Method and system for providing a contiguous memory address space

ABSTRACT

A memory system and a method for operating a memory system are provided. The memory system includes a set of memory banks, logic for calculating a first address in each memory bank from the set of memory banks and a controller receiving a transfer address from a computing device. The controller includes logic for selecting a memory bank from the set of memory banks based on the transfer address and the first addresses of the memory banks, and for mapping the transfer address to a target address in the selected memory bank based on a first address in the selected memory bank. As a result, the set of memory banks has a contiguous memory space.

FIELD OF THE INVENTION

[0001] This invention relates generally to a memory controller for a memory system and, more specifically, to a hardware memory controller providing a contiguous address space in a memory system with multiple memory banks.

BACKGROUND OF THE INVENTION

[0002] In computer processing systems, processing devices generally provide address signals to obtain access to other devices, such as memories. A memory device may be a memory system including multiple memory banks providing volatile data storage. There are numerous known memory types that can be used in processing systems. Synchronous Dynamic Random Access Memory (SDRAM) is a type of memory that is used in a wide variety of computer systems such as, for example, microprocessor and digital signal processor systems.

[0003] An SDRAM memory system may include a plurality of memory banks. Some memory systems permit banks of only one particular size, while others may permit banks of different sizes. Each memory bank may be divided into a plurality of pages. Pages are further logically divided into words. Words have a fixed number of bytes such as, for example, 16 bytes. Typically, an address sent from a processing device to the memory system indicates a particular word that is being accessed.

[0004] A number of address bits necessary to represent a location in a memory bank generally depends on the size of the memory bank, because the number of bits in the address must be sufficient to enumerate all possible addresses in the memory bank. For example, in systems where each byte can be addressed, at least 24 bits are needed to address each byte in a 16-megabyte memory bank (16 megabytes contain 2²⁴ bytes), and therefore a minimum address size for such a bank is 24 bits.

[0005] Although minimum address sizes vary for memory banks of different sizes, a memory system typically has one standard address size that is used by the processing device to indicate a word that is being accessed. The standard address size is typically at least the minimum size for the largest allowed memory bank. For example, in a byte-addressed system allowing for memory banks ranging in size from 2 megabytes to 128 megabytes, an address for a particular byte is at least 27 bits wide (128 megabytes contain 2²⁷ bytes). Additional address bits may be needed to indicate which of the memory banks is being addressed. For example, in a system having a maximum of 8 memory banks, at least 3 additional bits are needed to indicate location of the accessed word in one of the eight memory banks.

[0006] In a system that permits memory banks of different sizes, where all addresses are passed directly to the memory banks, there may be gaps in the address space—that is, there may not be any physical memory space corresponding to a particular set of addresses. Such gaps can occur when an address space is logically divided between available memory banks into equal subspaces. Some address subspaces may not be fully populated because they are larger than the actual memory bank to which they are assigned. For example, in a memory system allowing memory banks ranging from 2 to 128 megabytes, each memory bank may be allocated 2²⁷ addresses, which is appropriate for a 128 megabyte memory bank. However, when a memory bank smaller than the maximum size of 128 megabytes is used, some addresses have no corresponding physical memory space, thereby producing a gap in the address space between the end of the smaller memory bank and the beginning of the following memory bank. As a result of the gap, the address space for the system is not contiguous.

[0007] In a system that does not provide a contiguous memory space for software applications, each software program (and, correspondingly, each programmer writing programs for that system) needs to know which addresses are available and to request access to only those addresses. Knowing which addresses are available requires additional consideration and effort from the programmers and compilers, and makes programs more complex and less efficient.

[0008] Some memory systems incorporate memory management controllers that provide a contiguous address space. Those controllers, however, are typically highly complex and require complex interaction with an operating system, which is undesired in embedded processors, real time processors, microprocessors and digital signal processors. Therefore, a system is needed in which a contiguous memory address is provided without a significant computational overhead.

SUMMARY OF THE INVENTION

[0009] According to a first aspect of the invention, a method is provided for operating a memory system comprising a set of memory banks and a memory controller. The method comprises selecting a memory bank from the set of memory banks based on a transfer address and indicators of sizes of the memory banks, and mapping the transfer address to a target address in the selected memory bank based on a first address in the selected memory bank, wherein the set of the memory banks has a contiguous memory space.

[0010] According to another aspect of the invention, a memory system is provided. The memory system comprises a set of memory banks, logic for calculating a first address in each memory bank from the set of memory banks, and a controller receiving a transfer address from a computing device. The controller comprises logic for selecting a memory bank from the set of memory banks based on the transfer address and the first addresses of the memory banks and for mapping the transfer address to a target address in the selected memory bank based on a first address in the selected memory bank, wherein the set of memory banks has a contiguous memory space.

[0011] According to a further aspect of the invention, a memory system is provided. The memory system comprises a set of memory banks and a memory controller. The memory controller includes means for selecting a memory bank from the set of memory banks based on a transfer address and indicators of sizes of the memory banks, and means for determining a target address based on the transfer address and a first address in the selected memory bank, wherein the set of memory banks has a contiguous memory space.

BRIEF DESCRIPTION OF THE DRAWINGS

[0012]FIG. 1 is a schematic representation of a first prior art memory system with a memory controller determining target memory banks;

[0013]FIG. 2 is a schematic representation of a second prior art memory system with a memory controller determining target memory banks and programmable target memory bank address size;

[0014]FIG. 3 is a schematic representation of the memory system of an illustrative embodiment;

[0015]FIG. 4A is a schematic representation of size registers and associated adders of the illustrative embodiment;

[0016]FIG. 4B is a schematic representation of a memory controller of the illustrative embodiment;

[0017]FIG. 5 is a table illustrating possible encodings for bank memory sizes;

[0018]FIG. 6 is a table illustrating start address calculation;

[0019]FIG. 7 is a table illustrating an example of an implementation with start addresses corresponding to different memory banks.

DETAILED DESCRIPTION

[0020] The following detailed description should be read in conjunction with the attached drawings, in which similar reference numbers indicate similar structures. One embodiment is illustrated as a memory system with a hardware memory controller providing contiguous address memory space.

[0021] A processing device may include one or multiple processors for executing instructions. Such instructions may include memory access instructions which generate transfer requests. A processing system may have several memory levels, such as, for example, cache and memory. The processing device and associated cache located on the same chip may typically be referred to as “the core” or “the core processor” in a digital signal processor. The core may issue transfer requests to the memory system. The core and the memory system may be connected by one or multiple buses carrying addresses and data.

[0022] A memory system typically includes a memory controller and one or more memory banks. An illustrative embodiment of the invention includes a memory system with SDRAM memory banks. The invention, however, is not limited to a particular kind of memory and may be used in conjunction with any number of memory types and memory systems.

[0023] The processing device may access memory in any of the available SDRAM memory banks by sending a command and an address signal. The address signal indicates the memory location that is being accessed by the processing device. The memory controller typically receives the address signal from the processing device and determines a target memory bank and the address of the accessed location in the target memory bank. The target memory bank address may also be referred to as the SD (SDRAM) address. Data may be read from or written to the accessed location in the target memory bank.

[0024] The memory controller may be implemented in software or hardware, although, practically, a hardware implementation often provides faster operation and less overhead. Discussed in connection with FIGS. 3-7 is a hardware memory system of an illustrative embodiment.

[0025]FIG. 1 is a schematic representation of a prior art memory system. Memory banks 102 a-102 x are connected to a memory controller 110 through enable lines 104 a-104 x and to a processing device through address lines 108. Encoded on lines 108 is a part of a transfer address. A transfer address is an address received from a processing device. The transfer address is N bits wide. Some bits of the transfer address may be passed directly to the memory banks on lines 108, and some may be connected to the memory controller that determines the target memory bank on lines 106.

[0026] Typically, address lines 106 carry the bits necessary to determine the target memory bank for the address. A notation TA[a:b] is used to indicate that bits a through b of the transfer address are carried on those lines. If there are 2^(n) memory banks, then a minimum of n bits are required to encode the target memory bank; these are bits TA[N−1:N−n].

[0027] The memory controller may be a simple decoder, which selects one of the 2^(n) outputs based on n inputs. Enable lines 104 a-104 x carry results of the decoding to the memory banks 102 a-102 x, respectively. Each memory bank 102 has a corresponding enable input 112. Enable lines 104 a-104 x are connected to enable inputs 112 a-112 x, respectively. When an enable input for a particular memory bank is asserted, that memory bank is said to be enabled, and it responds to the command from the processing device. Only the enable input of the target memory bank is asserted, and all other enable inputs are deasserted.

[0028] Address lines 108 carry the address of the accessed location in a memory bank, encoded in the first (N−n) bits of the transfer address. Typically, lines 108 are arranged such that all memory banks receive identical inputs. However, only the target memory bank responds to the command from the processing device because only the target memory bank is enabled.

[0029] With such an arrangement, the address memory space is logically divided into 2^(n) equal subsets of addresses, each corresponding to one of 2^(n) memory banks. Each subset has 2^((N−n)) addresses, where 2^((N−n)) is the size of the largest allowed memory bank. If a particular system has memory banks that are not of the maximum allowed size, then in such a system the available physical address space is not contiguous because subsets of the addresses belonging to smaller-than-largest-allowed memory banks are not fully populated. For example, in a system that supports memory banks up to 128 megabytes, subsets of addresses are 2²⁷ bytes. If the first installed memory bank is 16 megabytes and the second bank is 128 megabytes, only 2²⁴ addresses are physically available in the address subset corresponding to the 16 megabyte memory bank. Therefore, a programmer writing programs for such a system must account for the non-contiguous memory space, which produces a gap in addresses between the end of the first bank and beginning of the second bank.

[0030] Traditionally, the lower bits of the transfer address (i.e. bits TA[N−1−n:0]) are passed directly to the memory banks because they provide a contiguous address space within each subset of the addresses. If the subsets of the addresses are not themselves contiguous, the programming difficulty of keeping track of which addresses are available increases manifold.

[0031]FIG. 2 is a schematic representation of a second prior art memory system that permits a programmable target memory bank address size. In this system, 2^(n) memory banks 202 a-202 x are connected to a memory controller 210 through enable lines 204 a-204 x and through lines 214, which carry high order target memory bank address bits (SD address bits), and to a processing device through lines 208, which carry the low order address bits. The memory controller is connected to the processing device through lines 306, which carry high order target address bits.

[0032] Address lines 208 carry the s lowest order bits of the transfer address (bits TA[s−1:0]) directly to the lower order bits of the memory banks, where 2^(s) is the size of the smallest supported memory bank. The rest of the address bits (bits TA[N−1:s]) are supplied to the memory controller 210.

[0033] The memory controller 210 may include logic 216 that is programmed with the value m, such that 2^(m) is the size of the largest installed memory bank (which may be smaller than the largest allowed memory bank). When the largest installed memory bank is of the largest allowed size, m=(N−n).

[0034] Once programmed with the value m, the memory controller logic 216 passes m−k of the lower order address bits (bits TA[m−1:s]) to lines 214 and uses a decoder 218 to determine the target memory bank from the next n bits (bits TA[m+n−1:m]).

[0035] In this configuration, the address space is logically divided into subsets of size 2^(m) addresses. If all installed memory banks are of the same size (2^(m) bytes), the memory address space may be contiguous, even if the installed memory banks are not of the maximum allowed size. However, if at least one of the installed memory banks is different in size from the others, the address space is not contiguous. Therefore, the programs running on such systems still need to keep track of which addresses are available and which are not. Furthermore, size m must be programmed in the system for each particular configuration.

[0036]FIG. 3 is a schematic representation of a memory system of an illustrative embodiment of the invention. Memory banks 302 a-302 x are connected to a memory controller 310 through enable lines 304 a-304 x and to a processing device through address lines 308. Encoded on lines 308 is part of a transfer address which constitutes lower order bits of the SD address. Lines 314 carry the remaining bits of the SD address.

[0037] In a system with allowed memory bank sizes from 2^(s) (size of the smallest allowed memory bank) to 2^(k) (size of the largest allowed memory bank), lines 314 carry bits SDA[N−n:s]. The present invention is not limited to systems where the allowed sizes of the memory banks are powers of two. In a system where memory bank sizes are not powers of two, the next higher power of two may be used for the purpose of calculating the minimum number of bits required to carry each part of the SD address.

[0038] The minimum size of the transfer address, N, may be calculated such that N=n+k. Memory controller 310 receives transfer address bits TA[N−1:s] as inputs and provides signals on enable lines 304 a-304 x and SD address lines 314. Registers 316 a-316 x and 318 provide bank start address inputs to the memory controller 310 as described below.

[0039] Memory controller 310 determines the target memory bank based on its inputs and maps (k−s) bits of the target address to the SDRAM address for the target memory bank. That is, the SD address is not identical to a portion of the target address as described in the systems of FIGS. 1 and 2. Memory controller 310 performs address translation, thus providing a contiguous memory address space to the processing device. This address translation is efficient because it takes place in hardware and involves only a subset of the address bits. The number of bits that require translation is the minimum number of bits required to represent all allowable memory bank sizes and may vary from system to system. Implementation and operation of registers 316 and 318 and memory controller 310 are further described below in connection with FIGS. 4-7.

[0040]FIG. 4A is a schematic representation of size registers and associated adders of the illustrative embodiment. Bank size registers 416 a-x and adders 402 a-402(x−1) are used to compute start addresses for each memory bank. Bank size registers hold the sizes of the respective memory banks, and that information is entered by the programmer. Although registers BS0, BS1, BS2, and BS3 are shown in FIG. 4A, the present invention is not limited to systems with four memory banks. Furthermore, representations of sizes of particular registers and numbers of bits required for particular computations are shown for illustrative purposes only and are not limiting. The system may be modified for a variety of memories of different sizes, as is understood by one skilled in the art.

[0041] Illustrated in FIGS. 4A-7 is an embodiment of the invention which permits at most 4 memory banks, with allowed bank sizes of 16 megabytes, 32 megabytes, 64 megabytes, and 128 megabytes. Consequently, variables s, k, N, and n may be calculated as follows:

[0042] The size of the smallest allowed memory bank is

2²⁴ bytes=2^(s) →s=24.

[0043] The size of the largest allowed memory bank is

2²⁷ bytes=2^(k) →k=27.

[0044] Maximum number of memory banks is

4=2^(n) →n=2.

[0045] N=k+n=27+2=29 bits.

[0046] Thus, the transfer address contains 29 bits.

[0047] Registers BSA0-BS3 each hold (k−s+n)=27−24+2=5 bits.

[0048] An example of bank size encoding for registers 416 is illustrated in FIG. 5. For example, a 16 megabyte memory bank may have its size encoded as 00001, and this value may be held in bank size register 416 a. The present invention is not limited to the illustrated memory bank size encodings, and other bank size encodings may be utilized.

[0049] The memory address space for each memory bank is contiguous. Therefore, the starting address for each of the memory banks and for the beginning of the unpopulated/reserved space may be determined by adding the sizes of each bank that precedes that bank. This may be done by summing the bank size encodings listed in FIG. 5 for each bank, as shown in FIG. 6. If the size of all installed memory banks is 128 megabytes, then the address space is fully populated. If any bank is less than 128 MB, the address space after the last bank is referred to as “unpopulated/reserved” space. Any access to unpopulated/reserved space may generate an internal bus error.

[0050] Adders 402 a-402 c may be used to perform computation of the start addresses for the memory banks. Each of adders 402 a-402 c sums a bank start address and a corresponding encoded bank size and outputs a start address of the following memory bank. Results of the additions are bank start addresses 316 a-316 x, which are input to memory controller 310.

[0051] A sample start address table is shown in FIG. 7. For example, in a system with memory banks of the following sizes: 32 MB, 32 MB, 16 MB, and 64 MB, start addresses 702 a-702 x, respectively, may be obtained. Reserved space may be indicated by address 718. Any request for an address that is higher than address 718 results in an error.

[0052]FIG. 4B is a schematic representation of memory controller 310 of the illustrative embodiment. When memory controller 310 receives a transfer address 306, the transfer address is compared by subtractors 412 a-412 x with the upper order bits of the start address of each bank. Comparison is performed by subtracting high order bits of the start address of each bank from high order bits of the transfer address. If the result of subtraction is negative, as indicated by the appropriate borrow output of the subtractor, then the preceding memory bank is selected by combination logic 414 as the target memory bank. The different outputs of subtractors 412 a-412 x are supplied to respective inputs of a multiplexer 410.

[0053] Logically, if a start address for a particular bank is larger than the transfer address, then the transfer address is not located in that particular memory bank or any of the following memory banks. Therefore, the transfer address is located in one of the preceding memory banks. More than one borrow may be positive, because there may be more than one memory bank for which the start address is larger than the transfer address. By selecting the memory bank with the largest start address for which the result of the subtraction is positive, memory controller 310 selects the correct target memory bank.

[0054] Combination logic 414 receives borrows 418 a-418 x as inputs and outputs control signals to multiplexer 410 which, in turn selects an output from one of the subtractors 412 a- 412 x to pass on as part of the SD address. As described above, the combination logic 414 selects the memory bank with the largest start address for which the result of the subtraction, as indicated by the borrow outputs of subtractors 412 a-412 x, is positive. Combination logic 414 also outputs results on the enable lines 304, enabling the target memory bank.

[0055] Mapping of the transfer address to the SD address results from this selection because results of the subtraction become new high order bits for the SD address, which is the target memory bank address. In the illustrative embodiment of the invention, one set of subtractors is used to determine the target memory bank and to perform the address mapping. In an alternative embodiment of the invention, different sets of combination logic may be used to determine the target memory bank and to perform the address mapping. sizes for those nonexistent memory banks into memory bank size registers and then set those locations as disabled, thus guaranteeing that any logical part of the memory address space falling to those locations will be inaccessible.

[0056] Contiguous memory address space is achieved through hardware memory address mapping. As a result, programs running on the processing devices may allocate memory regions without knowledge of the specific location of those regions within different memory banks. Furthermore, it may be possible to use only the desired amount of memory. For example, in a system where 144 MB are desired for a particular implementation, memory banks of 128 MB an 16 MB may be installed, and memory may be allocated without regard to where a particular part of the allocated memory is physically located. Therefore, programs and compilers may avoid overhead that would otherwise be associated with memory management functions.

[0057] It should be understood that the present invention is not limited to the system of the illustrative embodiment. All combination logic may be modified and adapted as appropriate for a particular implementation and as deemed appropriate by one skilled in the art. As should be further recognized by one skilled in the art, the present invention is not limited to the particular memory sizes or register or word sizes described in connection with the illustrative embodiment. Any number of memory types and sizes may be used as appropriate for a particular implementation of the invention. 

What is claimed is:
 1. A method for operating a memory system comprising a set of memory banks and a memory controller, said method comprising: selecting a memory bank from the set of memory banks based on a transfer address and indicators of sizes of the memory banks; and mapping the transfer address to a target address in the selected memory bank based on a first address in the selected memory bank, wherein the set of memory banks has a contiguous memory space.
 2. The method of claim 1, wherein selecting the memory bank comprises subtracting the indicators of the sizes of the memory banks from bits in the transfer address.
 3. The method of claim 2, wherein selecting the memory bank further comprises selecting a memory bank with the largest first address for which results of the subtraction are positive.
 4. The method of claim 2, wherein the subtracting is performed in parallel.
 5. The method of claim 4, wherein the indicator of the size of a memory bank is a subset of bits in a first address in the next memory bank.
 6. The method of claim 1, further comprising computing a first address in each of the memory banks in the set of memory banks.
 7. The method of claim 6, wherein computing a first address in a memory bank comprises adding contents of a size register for a previous memory bank to a first address in the previous memory bank.
 8. The method of claim 1, further comprising enabling the selected memory bank.
 9. The method of claim 1, further comprising returning an error if the selected memory bank is disabled.
 10. The method of claim 1, further comprising computing an indicator of a size of total memory available.
 11. The method of claim 10 further comprising: subtracting the indicator of the size of the total memory available from appropriate bits of the address; and returning an error if result of the subtraction is positive.
 12. The method of claim 1, wherein mapping the transfer address to the selected memory bank address further comprises subtracting a subset of bits in the first address in the selected memory bank from the transfer address.
 13. A memory system comprising: a set of memory banks; logic for calculating a first address in each memory bank from the set of memory banks; and a controller receiving a transfer address from a computing device, said controller comprising logic for selecting a memory bank from the set of memory banks based on the transfer address and the first addresses of the memory banks and for mapping the transfer address to a target address in the selected memory bank based on a first address in the selected memory bank, wherein the set of memory banks has a contiguous memory space.
 14. The memory system of claim 13, wherein the logic for calculating a first address in each memory bank comprises adders for adding an indicator of a size of a previous memory bank to appropriate bits in a first address in the previous memory bank.
 15. The memory system of claim 14, further comprising a set of registers containing indicators of memory bank sizes.
 16. The memory system of claim 15, wherein an indicator of a size of a memory bank for each memory bank is w bits wide, where w is a number of bits sufficient to represent all allowed memory bank sizes.
 17. The memory system of claim 16, wherein w=k−s+n where 2^(k) is the largest allowed bank size and 2^(s) is the smallest allowed bank size, and wherein 2^(n) is the closest approximation of the number of memory banks.
 18. The memory system of claim 13, wherein the logic for selecting the memory bank comprises subtractors for subtracting a subset of bits of the first addresses of the memory banks from bits of the transfer address.
 19. The memory system of claim 18, wherein the selected memory bank is a memory bank with the largest first address for which results of the subtraction are positive.
 20. The memory system of claim 13, further comprising logic for enabling the selected memory bank.
 21. The memory system of claim 13, wherein the controller further comprises logic for determining a target address in the selected memory bank.
 22. The memory system of claim 21, wherein the logic for determining the target address in the selected memory bank further comprises a subtractor for subtracting a subset of bits of a first address in the selected memory bank from a subset of bits in the transfer address.
 23. The memory system of claim 13, wherein the controller further comprises logic to return an error if the selected memory bank is disabled.
 24. The memory system of claim 13, wherein the controller further comprises logic to return an error if the transfer address is outside of an available range of addresses.
 25. The memory system of claim 24, wherein the logic to return an error if the address is outside of the available range further comprises a subtractor to subtract an indicator of total available memory size from a subset of bits of the transfer address, and logic to return the error if result of the subtraction is positive.
 26. A memory system comprising: a set of memory banks; and a memory controller including: means for selecting a memory bank from the set of memory banks based on a transfer address and indicators of sizes of the memory banks; and means for determining a target address based on the transfer address and a first address in the selected memory bank, wherein the set of memory banks has a contiguous memory space.
 27. The system of claim 26, wherein said means for selecting a memory bank further comprises means for subtracting the indicators of the sizes of the memory banks from bits in the transfer address.
 28. The system of claim 26, further comprising means for computing a first address in a memory bank for each of the memory banks in the set of memory banks.
 29. The system of claim 28, wherein the means for computing a first address in a memory bank comprises means for adding contents of a size register for a previous memory bank to a first address in the previous memory bank.
 30. The system of claim 26, further comprising means for returning an error if the target memory bank is disabled.
 31. The system of claim 26, wherein the means for determining a target memory bank address further comprises means for subtracting the first address in the selected memory bank from the transfer address. 